import React,{Component} from 'react';

//受控组件
class ControlledForm extends Component{
  	constructor(props){
  		super(props);
  		this.state={
  			username:'s'
  		}
  		this.handleSubmit= this.handleSubmit.bind(this);
  		this.updateUsername=this.updateUsername.bind(this);

  	}
  	updateUsername(e){
  		this.setState({
  			username:e.target.value,
  		});
  	}
  	handleSubmit(){

  	}
  	render(){
  		return (
  			<form>
  				<input
  					type='text'
  					value={this.state.username}
  					onChange={this.updateUsername}
  					/>
  					<button type='submit'>Submit</button>
  			</form>
  			);
  	}
}

export default ControlledForm;		